package com.example.eventbusdemo;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

import androidx.appcompat.app.AppCompatActivity;

/**
 * @author wdl
 */
public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        EventBus.getDefault().register(this);
        startActivity(new Intent(this, SecondActivity.class));

    }

    /**
     * 使用Subscribe标识需要放入EventBus数据源中的方法
     */
    @Subscribe(threadMode = ThreadMode.MAIN)
    public void getMessage(User user) {
        Log.d("TAG", "getMessage: " + user.getName() + user.getId());
        Log.d("TAG", "getMessage: " + Thread.currentThread().getName());
    }
}
